using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class CausalityObservationsAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public CausalityObservationsAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"AW","BE","DR","EX","IN","LI","OE","OT","PL","SE","TC"};
						validVersionCodes[HL7Version.v231] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
						validVersionCodes[HL7Version.v24] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
						validVersionCodes[HL7Version.v25] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
						validVersionCodes[HL7Version.v251] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
						validVersionCodes[HL7Version.v26] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
						validVersionCodes[HL7Version.v27] = new string[]{"AW","BE","LI","IN","EX","PL","TC","DR","SE","OE","OT"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Dose response observed","Alternative explanations for the event available","Event occurred after product introduced","Literature reports association of product with event","Occurrence of event was confirmed by objective evidence","Other","Effect observed when patient receives placebo","Similar events in past for this patient","Toxic levels of product documented in blood or body fluids"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Abatement of event after product withdrawn","Event recurred after product reintroduced","Literature reports association of product with event","Event occurred after product introduced","Alternative explanations for the event available","Effect observed when patient receives placebo","Toxic levels of product documented in blood or body fluids","Dose response observed","Similar events in past for this patient","Occurrence of event was confirmed by objective evidence","Other"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
